package com.elec.controller.end;

import com.elec.domain.R;
import com.elec.domain.entity.UsageData;
import com.elec.service.UsageDataService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author yu
 * @date 2024/7/6
 */
@RestController
@RequestMapping("end/usageData")
public class UsageDataController {
    @Resource
    private UsageDataService usageDataService;
    @PostMapping
    public R add(@RequestBody UsageData usageData){
        return usageDataService.add(usageData);
    }
    @DeleteMapping("{id}")
    public R delete(@PathVariable("id") Long id){
        return usageDataService.delete(id);
    }
    @PutMapping
    public R update(@RequestBody UsageData usageData){
        return usageDataService.update(usageData);
    }
    @GetMapping("{id}")
    public R get(@PathVariable("id") Long id){
        return usageDataService.get(id);
    }
    @GetMapping("list")
    public R getList(@RequestParam(defaultValue = "1") Integer pageNum,
                     @RequestParam(defaultValue = "10") Integer pageSize,
                     UsageData usageData){
        return usageDataService.getList(pageNum,pageSize,usageData);
    }
}
